const mutations = {

  getCityList: (state, res) => {
    // console.log(res)
    // 获得数据后，先根据属性shprt进行排序
    res.data.body.sort((a, b) => {
      const aa = a.short
      const bb = b.short
      if (aa < bb) {
        return -1
      } else if (aa === bb) {
        return 0
      } else {
        return 1
      }
    })
    state.cityList = res.data.body
    console.log(res.data.body)
  },
  getCityInfo: (state, val) => {
    state.city = val
    localStorage.setItem('cityName', val.name)
    localStorage.setItem('cityValue', val.value)
  },
  getCityRules: (state, val) => {
    const res = val.data.body
    state.cityRules = res
  },

  getToken (state, val) {
    state.token = val.token
    localStorage.setItem('token', val.token)
  },
  setHouseList (state, val) {
    state.houseList = val.data.body.list
  }
}
export default mutations
